﻿#region Copyright (C) Sector7 Software Studio. All rights reserved
/*******************************************************************************************
 * Creation
 *      Author:         Wolf Lai
 *      Date:           2011/10/27 22:14:19
 *      Version:        1.0.1101
 * Modification 
 *      Author: 
 *      Date: 
 *      Description: 
 *      Version:
 *******************************************************************************************/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;

namespace Sector7.Framework.Utility
{
    /// <summary>
    /// 计时器工具类
    /// </summary>
    public class TimerUtil
    {
        #region Public functions
        /// <summary>
        /// 启动计时器
        /// </summary>
        /// <param name="timer">计时器</param>
        public static void Start(Timer timer)
        {
            timer.Enabled = true;
            timer.Start();
        }

        /// <summary>
        /// 停止计时器
        /// </summary>
        /// <param name="timer">计时器</param>
        public static void Stop(Timer timer)
        {
            timer.Stop();
            timer.Enabled = false;
        }

        /// <summary>
        /// 重启计时器
        /// </summary>
        /// <param name="timer">计时器</param>
        public static void Restart(Timer timer)
        {
            Stop(timer);
            Start(timer);
        }
        #endregion
    }
}
